<template>
  <FormDialog
    :title="$t('workspace.SetHangUpTime')" 
    :visible="visible"
    @handleClose="handleClose">
  <template #content>
    <el-form :model="FormData" :rules="RulesFormData" ref="ruleForm">
      <el-form-item :label="$t('workspace.HangUpTime')" prop="timeNumber">
        <el-input type="number" v-model="FormData.timeNumber"></el-input>
      </el-form-item>
    </el-form>
  </template>
  <template #footer>
      <el-button @click="handleClose">{{ $t('common.cancel') }}</el-button>
      <el-button type="primary" @click="submit">{{ $t('common.confirm') }}</el-button>
  </template>
  </FormDialog>
</template>
<script lang="ts">
import Vue from 'vue'
import FormDialog from '../../../components/Dialog/formDialog.vue'
export default Vue.extend({
  components: {
    FormDialog
  },
  name:'SetHangUpTimeDialog',
  data() {
    return {
      visible:false,
      FormData:{
         timeNumber:18
      },
      RulesFormData:{
        timeNumber:[
          { validator: (rules:any,value:any,callback:any) => {
            if (value>1) {
                if (value%1===0) {
                  callback()
                } else {
                  callback(new Error((this as any).$t('workspace.desktopQuotaErrorTip')))
                } 
            } else {
              callback(new Error((this as any).$t('workspace.PleaseEnterGreaterThanOne')))
            }
          }, trigger: 'blur' }
        ]
      }
    }
  },
  methods:{
    init() {
      this.visible = true;
    },
    handleClose() {
      this.visible = false;
      this.FormData.timeNumber = 18;
    },
    submit() {
      (this as any).$refs.ruleForm.validate((valid:any) => {
        if(!valid) return this.$message.error('验证未通过')
      });
    }
  }
})
</script>
<style lang="scss" scoped>

</style>